using UnityEngine;
using QFramework;
using Cinemachine;
using Cysharp.Threading.Tasks;

public class Stage : AbstractSystem
{
    public Snake Snake;
    public Transform StageRoot;
    public StageModel StageModel;
    public CinemachineConfiner2D Confiner2D;

    protected override void OnInit()
    {
        StageModel = this.GetModel<StageModel>();
    }

    public void InitStage()
    {
        var stagePrefab = StageModel.m_StageData.StagePrefab;
        GameObject.Instantiate(stagePrefab,StageRoot);
        Snake.initSpeed = StageModel.m_StageData.InitSpeed;
        Snake.initLenght = StageModel.m_StageData.InitLenth;
        var ConfinerGO = GameObject.Instantiate(StageModel.m_StageData.Confiner);
        var Collider2D = ConfinerGO.GetComponent<Collider2D>();
        Confiner2D.m_BoundingShape2D = Collider2D;
        this.SendEvent<GameInitFinish>();
    }
}